<?php
class MessageModel{
    protected $content='';
    protected $date='';
    protected $user_id='';
    protected $tags='';
    protected $img='';
    protected $id='';
    protected $mapper;
    protected $video='';
    protected $private='';
    protected $new = 0;

    public function save(){
        $this->getMapper()->save($this);
        return $this;
    }

    public function edit(){
        $this->getMapper()->edit($this);
        return $this;
    }

    public function delete(){
        $this->getMapper()->delete($this);
        return $this;
    }

    public function find($userId){
        $this->getMapper()->find($userId, $this);
        return $this;
    }

    public function fetchAllMessages($page, $count){
        return $this->getMapper()->fetchAllMessages($page, $count);

    }

    public function fetchAllMessagesByTagId($tag_id){
        return $this->getMapper()->fetchAllMessagesByTagId($tag_id);

    }

    public function fetchAllMessagesByUserId($user_id){
        return $this->getMapper()->fetchAllMessagesByUserId($user_id);

    }

    public function fetchAllPrivateMessages($user_id){
        return $this->getMapper()->fetchAllPrivateMessages($user_id);
    }

    public function fetchAllSendedMessages($user_id){
        return $this->getMapper()->fetchAllSendedMessages($user_id);
    }

    public function getCounter(){
        return $this->getMapper()->getCounter();
    }


//=====================================================================
    public function setContent($_content){
        $this->content = $_content;
        return $this;
    }
    public function getContent(){
        return $this->content;
    }

    public function setNew($_new){
        $this->new = $_new;
        return $this;
    }
    public function getNew(){
        return $this->new;
    }

     public function setPrivate($_private){
        $this->private = $_private;
        return $this;
    }
    public function getPrivate(){
        return $this->private;
    }

    public function setImg($_img){
        $this->img = $_img;
        return $this;
    }
    public function getImg(){
        return $this->img;
    }

    public function setTags($_tag){
        $this->tags = $_tag;
        return $this;
    }
    public function getTags(){
        return $this->tags;
    }

    public function setVideo($_video){
        $this->video = $_video;
        return $this;
    }
    public function getVideo(){
        return $this->video;
    }

    public function setDate($_date){
        $this->date = $_date;
        return $this;
    }
    public function getDate(){
        return $this->date;
    }

    public function setId($_id){
        $this->id = $_id;
        return $this;
    }
    public function getId(){
        return $this->id;
    }

    public function setUserid($_user_id){
        $this->user_id = $_user_id;
        return $this;
    }
    public function getUserid(){
        return $this->user_id;
    }

    public function setMapper($_mapper){
        $this->mapper = $_mapper;
        return $this;
    }
    public function getMapper(){
        if(!isset($this->mapper)){
            return $this->setMapper(new MessageMapper());
        } else {
            return $this->mapper;
        }
    }
}
?>
